package com.zklh.leetcode.lcp;

/**
 * @version 1.0
 * @Author tongnan
 * @Date 2023/9/15
 */
public class SolutionLCP50 {
    public int giveGem(int [] gem, int[][] operations) {
        for (int[] operation : operations) {
            gem[operation[1]] += gem[operation[0]] / 2;
            gem[operation[0]] -= gem[operation[0]] / 2;
        }
        int max = 0, min = Integer.MAX_VALUE;
        for (int i : gem) {
            min = Integer.min(min, i);
            max = Integer.max(max, i);
        }
        return max -min;
    }
}